import axios from 'axios'

// 拦截器

// 请求拦截器
axios.interceptors.request.use((cfg) => {
    let token = localStorage.getItem('token')
    if (token) {
        cfg.headers.authorzation = token
    }
    // console.log('请求拦截器');
    return cfg
})
// 响应拦截器
axios.interceptors.response.use((res) => {
    if(res.data.code === 0 && res.data.token){
        // console.log(res);
        localStorage.setItem('token',res.data.token)
        console.log(localStorage.getItem('token'));
      }
    return res.data
})

export default axios